﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using connect;
using Pharmacy_management_system;
using System.Collections;

namespace Pharmacy_management_system
{
    public partial class mimaxiugai : Form
    {
        public mimaxiugai()
        {
            InitializeComponent();
        }
        //确定
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text != textBox2.Text)
            {
                MessageBox.Show("再次输入的密码不一致,请重新输入密码", "密码修改");
                textBox1.Focus();
            }
            if (textBox1.Text == textBox2.Text)
            {
                SqlConnection con = new SqlConnection(SQL.constr);
                string cmdText = "update sys_sys_users set pass_word='" + textBox1.Text + "' where user_name='" + PassSystem.UserID + "'";
                SqlCommand cmd = new SqlCommand(cmdText, con);
                con.Open();
                cmd.ExecuteNonQuery();
                con.Close();
                DialogResult res=MessageBox.Show("密码设置成功，请使用新密码登录系统", "密码修改",MessageBoxButtons.OKCancel);
                if (res == DialogResult.OK)
                {
                    this.Close();
                }
               
            }
        }
        //取消
        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void textBox1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                textBox2.Focus();
            }
        }

        private void textBox2_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                button1_Click(sender, e);
            }
        }
    }
}
